cmrobobitsfandomcom-20200213-history
Vision Toolkit
The Vision toolkit is available for download for groups that wish to perform some sort of vision operation on the Naos. We provide the following tools: * NaoImageCapture ** a helper class that grabs images from the Naos * CMVision ** thresholds images from pixels to colors (e.g., green, blue), and forms regions * CMVEdit ** allows editing of thresholds Where to get it In order to download the Vision toolkit, please contact Som for the download address. How to use the Vision toolkit In the .tar.gz file, you'll find a couple of sub-directories: CMVEdit, cmvision, config, shared, NaoImageCapture. config Contains config.txt (which sets the camera parameters), colors.txt (which defines the colors in the world, i.e. red, green, blue etc) - you shouldn't need to edit this file, and threshold.tmap.gz (which is read by cmvision). NaoImageCapture This is a helper class that grabs images from the camera and returns a pointer to it. In NaoImageCapture.h, there is a #define REMOTE that you need to comment out if you are running code on the robot. This class reads the config file and sets camera paramters as defined in the config file. It currently reads 320x240 in YUV422 format. Try not to change this unless necessary, as corresponding changes will have to be made in CMVision. cmvision This is a slightly-modified CMVision code that will work on the Naos. vision.h and vision.cpp are the main files you should look at. Basically, you call cmvision.init("colors.txt", "threshold.tmap.gz", image width, image height) to initialize it. Then, you create a vision_image object (say cmvImage), set the width (320), height (240), pitch (640), and field (field should be 0). To fill out the vision_image, you set cmvImage.buf = (pixel *)image, where image is the pointer to the pixels you get from NaoImageCapture. Then, you call cmvision.processFrame(cmvImage) to actually process the image. You can then access the regions by: Region *reg = cmvision.colorOrange.list for example. CMVEdit CMVEdit is a program that generates thresholds. Please refer to its page for more specific instructions on how to use it. It reads the files in its config directory (CMVEdit/config) in order to work, and loads and saves thresholds as CMVEdit/config/thresh0.tmap.gz. It is important to copy this threshold file into the other config directory when you want to use NaoImageCapture. shared This directory contains other helper classes, like the ConfigFile, and Vector2D, Vector3D. Not all the classes are actually used. config This directory contains the config file (config.txt), which defines the camera parameters. Also, the threshold file used by your project (threshold.tmap.gz) is loaded from this directory. colors.txt defines the colors (e.g., green, blue) and should not be changed unless necessary. Corresponding changes will have to be made in CMVision, CMVEdit and so on. Compiling the Vision toolkit When you compile, it is important that you include the zlib library. In Ubuntu, you can install the package zlib1g-dev to get it for your computer. In the project directory, you need to edit CMakeLists.txt and add the following line: FIND_PACKAGE( ZLIB REQUIRED ) In the project/src directory, you need to edit CMakeLists.txt, and in the line: TARGET_LINK_LIBRARIES( .... ), add ${ZLIB_LIBRARIES} Finally, in the naoqi/cmakemodules directory, add the file FindZLIB.cmake. If you need this file, contact Som for the download address.